"""
演示数据容器之字典的定义
"""

# 定义字典
dict_1 = {"张三": 99, "李四": 88, "王五": 77}
dict_2 = {}
dict_3 = dict()
print(f"dict1的内容：{dict_1}，类型为：{type(dict_1)}")
print(f"dict2的内容：{dict_2}，类型为：{type(dict_2)}")
print(f"dict3的内容：{dict_3}，类型为：{type(dict_3)}")
print("-------------------------------------------")

# 定义重复key的字典
dict_1 = {"张三": 98, "张三": 88, "王五": 77}
print(f"重复key的字典内容是：{dict_1}")
print("-------------------------------------------")

# 从字典中基于key获取value
dict_1 = {"张三": 99, "李四": 88, "王五": 77}
key = "李四"
print(f"张三的考试分数是：{dict_1['张三']}")
print(f"{key}的考试分数是：{dict_1[key]}")
print("-------------------------------------------")

# 定义嵌套字典
stu_score_dict = {
    "王丽红": {
        "语文": 77,
        "数学": 66,
        "英语": 33
    },
    "周杰轮": {
        "语文": 88,
        "数学": 86,
        "英语": 55
    },
    "林君姐": {
        "语文": 99,
        "数学": 96,
        "英语": 66
    }
}
print(f"学生成绩信息字典内容为：{stu_score_dict}")
print("-------------------------------------------")
# 从嵌套字典中获取数据
# 查周杰轮的语文成绩
print(f"周杰轮的语文成绩是：{stu_score_dict['周杰轮']['语文']}")
# 查林君姐的英语成绩
print(f"林君姐的英语成绩是：{stu_score_dict['林君姐']['英语']}")
